﻿#ifndef ADDFRIENDDIALOG_H
#define ADDFRIENDDIALOG_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include "protocol.h"
#include <QGridLayout>

namespace Ui {
class AddFriendDialog;
}

class AddFriendDialog : public QWidget
{
    Q_OBJECT

public:
    explicit AddFriendDialog(QWidget *parent = nullptr);
    ~AddFriendDialog();

    static AddFriendDialog* getInstance();

    void setAvatar(QString imgPath, int radius);
    void setUsrName(QString usrName);
    void setMsg(QString Msg);

    void handleSearch(PDU *pduRecv);

    void handleAddFriendRespond(PDU* pduRecv);

private slots:
    void on_pbn_Search_clicked();

    void slot_pbn_addFriend_clicked();

private:
    Ui::AddFriendDialog *ui;
    //用于显示搜索结果
    QGridLayout *m_pGridLayout = NULL;
    QLabel* lb_usrName = NULL;
    QLabel* lb_Msg = NULL;
    QLabel* lb_avatar = NULL;
    QPushButton* pbn_addFriend = NULL;

    QString friendUsrName;

    // 设置是否显示 widget（显示搜索结果）
    // isShow ：true 显示，false 不显示
    void isShowWidget(bool isShow);

protected:
    void showEvent(QShowEvent *event) override;
    bool    event(QEvent* e) override;
};

#endif // ADDFRIENDDIALOG_H
